package com.ruiysoft.service.order.consts;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * Date : 2018/11/24
 *
 * @author WenJialu
 */
public enum OrderOperateTypeEnum {

	/*
	* 1 订单生成
            2 用户付款
            3 用户已付款 平台确认
            4 平台已确认付款 商铺确认
            5 发货
            6 确认收货
            71 收货
            72 系统签收订单
            11 申请换货
            12 商铺确认换货
            21 申请退货
            22 商铺确认退货
            23 商铺退款
            97 订单取消
            98 订单关闭
            99 订单完结*/

	ORDER_CREATE(1, "订单生成，待用户确认"),
	GET_GENERATE_PAY_TRANSACTION(101, "支付流水号"),
	CUSTOMER_PAID(2, "用户付款"),
//	CUSTOMER_PAID_CALLBACK(201, "用户支付回调"),
	PLATFORM_CONFIRMED_PAID(3, "平台确认付款"),
	SHOP_CONFIRMED_PAID(4, "商铺确认付款"),
	DELIVER(5, "发货"),
	RECEIVE_CONFIRM(71, "收货确认"),
	SYSTEM_SIGN(72, "系统签收订单"),
	BARTER(11, "申请换货"),
	BARTER_SHOP_CONFIRM(12, "商铺确认换货"),
	RETURNED_PURCHASE(21, "申请退货"),
	RETURNED_PURCHASE_CONFIRM(22, "商铺确认退货"),
	SHOP_REFUND(23, "商铺退款"),
	ORDER_CANCELL(97, "订单取消"),
	ORDER_CLOSE(98, "订单关闭"),
	ORDER_OVER(99, "订单完结");

	private Integer code;
	private String text;

	private static Map<Integer, OrderOperateTypeEnum> typeEnumMap = null;

	OrderOperateTypeEnum(Integer code, String text) {
		this.code = code;
		this.text = text;
	}


	public static OrderOperateTypeEnum getInstanceByCode(Integer code){
		if (null == typeEnumMap) {
			typeEnumMap = Arrays.stream(OrderOperateTypeEnum.values()).collect(Collectors.toMap(OrderOperateTypeEnum::getCode, typeEnum -> typeEnum));
		}
		return typeEnumMap.get(code);
	}

	public Integer getCode() {
		return code;
	}

	public String getText() {
		return text;
	}
}
